﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1002319, 0),
Array("", 1002320, 0),
Array("", 1002321, 0),
Array("", 1002322, 0),
Array("", 1002331, 0),
Array("", 1002332, 0),
Array("", 1002334, 0),
Array("", 1002335, 0),
Array("", 1002336, 0),
Array("", 1002337, 0),
Array("", 1002341, 0),
Array("", 1002342, 0),
Array("", 1002343, 0),
Array("", 1002344, 0),
Array("", 1002345, 0),
Array("", 1002346, 0),
Array("", 1002347, 0),
Array("", 1002348, 0),
Array("", 1002349, 0),
Array("", 1002350, 0),
Array("", 1002351, 0),
Array("", 1002352, 0),
Array("", 1002353, 0),
Array("", 1002354, 0),
Array("", 1002355, 0),
Array("", 1002356, 0),
Array("", 1002358, 0),
Array("", 1002359, 0),
Array("", 1002360, 0),
Array("", 1002361, 0),
Array("", 1002362, 0),
Array("", 1002367, 0),
Array("", 1002368, 0),
Array("", 1002369, 0),
Array("", 1002370, 0),
Array("", 1002371, 0),
Array("", 1002372, 0),
Array("", 1002373, 0),
Array("", 1002374, 0),
Array("", 1002375, 0),
Array("", 1002376, 0),
Array("", 1002384, 0),
Array("", 1002385, 0),
Array("", 1002386, 0),
Array("", 1002387, 0),
Array("", 1002388, 0),
Array("", 1002389, 0),
Array("", 1002396, 0),
Array("", 1002397, 0),
Array("", 1002409, 0),
Array("", 1002410, 0),
Array("", 1002411, 0),
Array("", 1002412, 0),
Array("", 1002413, 0),
Array("", 1002414, 0),
Array("", 1002415, 0),
Array("", 1002416, 0),
Array("", 1002417, 0),
Array("", 1002420, 0),
Array("", 1002421, 0),
Array("", 1002422, 0),
Array("", 1002423, 0),
Array("", 1002426, 0),
Array("", 1002427, 0),
Array("", 1002428, 0),
Array("", 1002429, 0),
Array("", 1002431, 0),
Array("", 1002432, 0),
Array("", 1002433, 0),
Array("", 1002434, 0),
Array("", 1002435, 0),
Array("", 1002437, 0),
Array("", 1002438, 0),
Array("", 1002439, 0),
Array("", 1002440, 0),
Array("", 1002442, 0),
Array("", 1002443, 0),
Array("", 1002444, 0),
Array("", 1002445, 0),
Array("", 1002446, 0),
Array("", 1002447, 0),
Array("", 1002449, 0),
Array("", 1002450, 0),
Array("", 1002451, 0),
Array("", 1002456, 0),
Array("", 1002457, 0),
Array("", 1002458, 0),
Array("", 1002459, 0),
Array("", 1002460, 0),
Array("", 1002461, 0),
Array("", 1002462, 0),
Array("", 1002463, 0),
Array("", 1002464, 0),
Array("", 1002465, 0),
Array("", 1002466, 0),
Array("", 1002467, 0),
Array("", 1002468, 0),
Array("", 1002469, 0),
Array("", 1002470, 0),
Array("", 1002476, 0),
Array("", 1002477, 0),
Array("", 1002478, 0),
Array("", 1002479, 0),
Array("", 1002480, 0),
Array("", 1002481, 0),
Array("", 1002482, 0),
Array("", 1002484, 0),
Array("", 1002485, 0),
Array("", 1002486, 0),
Array("", 1002487, 0),
Array("", 1002488, 0),
Array("", 1002491, 0),
Array("", 1002493, 0),
Array("", 1002495, 0),
Array("", 1002496, 0),
Array("", 1002497, 0),
Array("", 1002498, 0),
Array("", 1002499, 0),
Array("", 1002500, 0),
Array("", 1002501, 0),
Array("", 1002502, 0),
Array("", 1002503, 0),
Array("", 1002504, 0),
Array("", 1002505, 0),
Array("", 1002506, 0),
Array("", 1002507, 0),
Array("", 1002512, 0),
Array("", 1002513, 0),
Array("", 1002519, 0),
Array("", 1002520, 0),
Array("", 1002521, 0),
Array("", 1002522, 0),
Array("", 1002523, 0),
Array("", 1002524, 0),
Array("", 1002525, 0),
Array("", 1002526, 0),
Array("", 1002534, 0),
Array("", 1002536, 0),
Array("", 1002544, 0),
Array("", 1002552, 0),
Array("", 1002555, 0),
Array("", 1002556, 0),
Array("", 1002557, 0),
Array("", 1002558, 0),
Array("", 1002559, 0),
Array("", 1002560, 0),
Array("", 1002566, 0),
Array("", 1002568, 0),
Array("", 1002569, 0),
Array("", 1002575, 0),
Array("", 1002576, 0),
Array("", 1002590, 0),
Array("", 1002591, 0),
Array("", 1002592, 0),
Array("", 1002597, 0),
Array("", 1002598, 0),
Array("", 1002599, 0),
Array("", 1002605, 0),
Array("", 1002607, 0),
Array("", 1002608, 0),
Array("", 1002650, 0),
Array("", 1002653, 0),
Array("", 1002654, 0),
Array("", 1002660, 0),
Array("", 1002661, 0),
Array("", 1002666, 0),
Array("", 1002667, 0),
Array("", 1002672, 0),
Array("", 1002673, 0),
Array("", 1002674, 0),
Array("", 1002678, 0),
Array("", 1002679, 0),
Array("", 1002691, 0),
Array("", 1002692, 0),
Array("", 1002693, 0),
Array("", 1002694, 0),
Array("", 1002696, 0),
Array("", 1002697, 0),
Array("", 1002698, 0),
Array("", 1002700, 0),
Array("", 1002701, 0),
Array("", 1002703, 0),
Array("", 1002704, 0),
Array("", 1002705, 0),
Array("", 1002706, 0),
Array("", 1002708, 0),
Array("", 1002709, 0),
Array("", 1002710, 0),
Array("", 1002711, 0),
Array("", 1002712, 0),
Array("", 1002713, 0),
Array("", 1002714, 0),
Array("", 1002715, 0),
Array("", 1002720, 0),
Array("", 1002721, 0),
Array("", 1002722, 0),
Array("", 1002724, 0),
Array("", 1002725, 0),
Array("", 1002726, 0),
Array("", 1002727, 0),
Array("", 1002734, 0),
Array("", 1002735, 0),
Array("", 1002736, 0),
Array("", 1002738, 0),
Array("", 1002745, 0),
Array("", 1002746, 0),
Array("", 1002747, 0),
Array("", 1002748, 0),
Array("", 1002752, 0),
Array("", 1002753, 0),
Array("", 1002754, 0),
Array("", 1002755, 0),
Array("", 1002756, 0),
Array("", 1002770, 0),
Array("", 1002771, 0),
Array("", 1002774, 0),
Array("", 1002784, 0),
Array("", 1002785, 0),
Array("", 1002796, 0),
Array("", 1002803, 0),
Array("", 1002804, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到时尚帽子店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}